
import {getNewsList} from '../../api/news';
var app = getApp()


Page({
  data: {
    defaultAvatarUrl : 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0',
    is_subscribe: 0,
    is_showOfficialcount: !1,
    showToastInfo: !1,
    topRadiusBgHeight: 0,
    totalHeight: 100,
    toptotalHeight: 100,
    statusBarHeight: 0,
    userinfo: null,
    showMiniLogin: !1,
    showStatus: !1,
    opengetLocation: !1,
    isRotate: !1,
    wechatImage: "",
    isShowQrCodeModal: !1,
    selopencity: !1,
    slide: [],
    cardCur: 0,
    navigation: [],
    hottags: [],
    indexCenterImg: "",
    searchval: "",
    pstatus: "more",
    pstatusn: "more",
    ppage: 1,
    ppagen: 1,
    ppagel: 1,
    psize: 20,
    psizen: 20,
    plist: [],
    plistn: [],
    plistl: [],
    plistAI: [],
    status: 0,
    latitude: 0,
    longitude: 0,
    useraddress: "",
    modal: {
        name: "",
        id: 0,
        index: 0,
        type: "",
        comjob: {}
    },
    catelist: [],
    workTypeList: "",
    actiontype: "",
    is_ai: 2,
    APPID: "wxbc84c763966541a7",
    PATH: "/pages/index/index",
    noticelist: [], //焦点资讯
    voiceing: !1,
    voicePath: "",
    voiceText: ""
  },
  onLoad() {
    this.get_news_list();
    
  },
  //焦点资讯
  get_news_list(){
    getNewsList({
      pageNo : 1,
      pageSize : 10
    }).then(res=>{
       this.setData({
        noticelist : res.data.list
       })
    })
  },
  nav_to(e){
    const url = e.currentTarget.dataset.url
    wx.reLaunch({
      url: url,
    })
  },
  onChooseAvatar(e) {
    const { avatarUrl } = e.detail
    const { nickName } = this.data.userInfo
    this.setData({
      "userInfo.avatarUrl": avatarUrl,
      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
    })
  },
 
  onInputChange(e) {
    const nickName = e.detail.value
    const { avatarUrl } = this.data.userInfo
    this.setData({
      "userInfo.nickName": nickName,
      hasUserInfo: nickName && avatarUrl && avatarUrl !== defaultAvatarUrl,
    })
  },
  getUserProfile(e) {
    // 推荐使用wx.getUserProfile获取用户信息，开发者每次通过该接口获取用户个人信息均需用户确认，开发者妥善保管用户快速填写的头像昵称，避免重复弹窗
    wx.getUserProfile({
      desc: '展示用户信息', // 声明获取用户个人信息后的用途，后续会展示在弹窗中，请谨慎填写
      success: (res) => {
        console.log(res)
        this.setData({
          userInfo: res.userInfo,
          hasUserInfo: true
        })
      }
    })
  },
})
